<?php

class Funds extends HTech_Db_Table implements Emms_Interface_Performance
{
    protected $_name    = 'view_funds';
    protected $_primary = 'FundId';
    
    protected $_dependentTables = array('LnkProgramsFunds');
    protected $_lnkTables = array('LnkProgramsFunds' => 'ProgramId');

    protected function _setGridMetadata()
    {
        $this->_gridMetadata['title'] = $this->translate("Funds");
        $this->_gridMetadata['onClick'] = 'admin.fund.view';
        $this->_gridMetadata['headers'] = array
            (
                array('FundId',            50, $this->translate("Id"),             'Number'),
                array('Code',             100, $this->translate("Code"),           'String'),
                array('Fund',             250, $this->translate("Fund"),           'String'),
                array('Status',           100, $this->translate("Status"),         'String'),
                array('LastEditDate',     200, $this->translate("Last edit date"), 'DateTime', 'Date'),
                array('LastEditFullName', 250, $this->translate("Last edit user"), 'String')
            );
        return $this;
    }
            
    protected function _setRecordDependentRows()
    {
        $this->_record->r = (object) array('programs' => null);
        $this->_record->r->programs = $this->_record->d->findManyToManyRowset('Programs','LnkProgramsFunds');
        array_walk($this->_record->r->programs->toArray(), array($this, '_setRecordLnkData'), array('LnkProgramsFunds', 'ProgramId'));
    }
        
    protected function _setRecordPerformance() 
    {
        $this->_record->p = $this->getPerformance($this->_record->d, new Zend_Date());
    }
    
    public function getPerformanceCharts(Zend_Db_Table_Row $row) {}
    public function getPerformance(Zend_Db_Table_Row $row, Zend_Date $date, $options = array()) {}
}